package com.hcc.repository.extension.mapper;

import com.hcc.repository.extension.conditions.ChainConditions;
import com.hcc.repository.extension.conditions.nativesql.NativeSqlChainCondition;
import com.hcc.repository.extension.conditions.query.DefaultQueryChainCondition;
import com.hcc.repository.extension.conditions.query.LambdaQueryChainCondition;
import com.hcc.repository.extension.conditions.update.DefaultUpdateChainCondition;
import com.hcc.repository.extension.conditions.update.LambdaUpdateChainCondition;
import com.hcc.repository.core.mapper.BaseMapper;

import java.io.Serializable;

/**
 * 支持链式的Mapper
 *
 * @author hushengjun
 * @date 2023/8/28
 */
public interface ChainMapper<T, ID extends Serializable> extends BaseMapper<T, ID> {

    /**
     * 默认的链式查询
     *
     * @return
     */
    default DefaultQueryChainCondition<T, ID> defaultQuery() {
        return ChainConditions.defaultQuery(this);
    }

    /**
     * lambda的链式查询
     *
     * @return
     */
    default LambdaQueryChainCondition<T, ID> lambdaQuery() {
        return ChainConditions.lambdaQuery(this);
    }

    /**
     * 默认的链式更新
     *
     * @return
     */
    default DefaultUpdateChainCondition<T, ID> defaultUpdate() {
        return ChainConditions.defaultUpdate(this);
    }

    /**
     * lambda的链式更新
     *
     * @return
     */
    default LambdaUpdateChainCondition<T, ID> lambdaUpdate() {
        return ChainConditions.lambdaUpdate(this);
    }

    /**
     * 原生的sql操作
     *
     * @return
     */
    default NativeSqlChainCondition<T, ID> nativeSql() {
        return ChainConditions.nativeSql(this);
    }

}
